package com.mjlf.algorithms.sort;

import com.mjlf.algorithms.TimeCount;

import java.util.Random;

/**
 * @auther a123
 * @create 2018-09-06 19:45
 * @desc 排序比较
 */
public class SortCompare {

    public static void main(String[] args){

        for(int i = 0; i < 100; i ++){
            Integer[] elements = new Integer[10000000];
            Integer[] elementsSelect = new Integer[10000000];
            Integer[] elementsShell = new Integer[10000000];
            Integer[] elementsMerge = new Integer[10000000];
            for(int j = 0; j < 10000000; j ++){
                int num = new Random().nextInt(1000);
                elements[j] = num;
                elementsSelect[j] = num;
                elementsShell[j] = num;
                elementsMerge[j] = num;
            }

//            TimeCount timeCountSelect = new TimeCount();
//            SelectionSort.sortByDown(elementsSelect);
//            System.out.println("select sortByDown : " + timeCountSelect.getUseTime());
//
//
//            TimeCount timeCount = new TimeCount();
//            InsertSort.sortFromIndexTuring(elements);
//            System.out.println("insert sortByDown : " + timeCount.getUseTime());
//
//            TimeCount timeCountShell = new TimeCount();
//            ShellSort.sortByDown(elementsShell);
//            System.out.println("shell sortByDown : " + timeCountShell.getUseTime());


//            TimeCount timeCountMerge = new TimeCount();
//            MergeSort.sortByDown(elementsMerge);
//            System.out.println("merge sortByDown : " + timeCountMerge.getUseTime());
//            System.out.println();

            TimeCount timeCountQuick = new TimeCount();
            HeapSort.sortByUp(elementsMerge);
//            Arrays.sortByDown(elementsMerge);
            System.out.println("quick sortByDown : " + timeCountQuick.getUseTime());
            System.out.println();

        }
    }
}
